﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/App.Master" Inherits="System.Web.Mvc.ViewPage<Ornament.MemberShip.User>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    创建用户
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <%
        Html.BeginForm();%>
    <div class="buttonContainer">
        <button type="submit" id="saveButton">
            创建</button>
        <button id="backButton" type="button">
            取消</button>
    </div>
    <div id="CreateUser">
        <ul>
            <li><a href="#base">必填项目</a> </li>
            <li><a href="#choose">选填项目</a> </li>
            <li><a href="#2">角色</a></li>
            <li><a href="#usergroup">用户组</a></li>
        </ul>
        <div id="base" class="cssform">
            <div class="fieldItem">
                <label for="LoginId">
                    登录名称:
                </label>
                <%=Html.TextBoxFor(model => model.LoginId)%>
                <script type="text/javascript">
                    $("#LoginId").vRequire({
                        errorText: "请填写登录名",
                        group: "base"
                    }).vLength({
                        min: 6,
                        max: 20
                    }).vRegex({
                        pattern: /[a-zA-z1-9_-]{6,20}/,
                        errorText: "必须为应为字符、数字、下划线、减号、并且区分大小写"
                    }).vAjax({
                        errorText: "登录名称已被其他人使用，请修改其他",
                        url: '<%=Url.Action("IsExit")%>',
                        data: function () {
                            return { userName: $("#LoginId").val() };
                        },
                        onEndRequest: function (result) { return !result.Result; }
                    });        
                </script>
            </div>
            <p>
                <label for="EmailTextBox">
                    E-Mail:
                </label>
                <%=Html.TextBoxFor(model => model.Email)%>
                <script type="text/javascript">

                    $("#Email").vRequire({
                        errorText: "请填写地址邮件地址",
                        group: "base"
                    }).vLength({
                        min: 6, max: 30, onerror: "电子邮件长度要在6只30之间"
                    }).vRegex({
                        pattern: /^([A-Za-z0-9_\.-]+)@([\da-zA-Z\.-]+)\.([a-zA-Z\.]{2,6})$/,
                        errorText: "电子邮件格式不正确"
                    });        
                </script>
            </p>
            <p>
                <label for="PasswordTextBox">
                    密码:
                </label>
                <%=Html.PasswordFor(model => model.Password)%>
                <script type="text/javascript">
                    $("#Password").vRequire({
                        errorText: "请输入至少" + passwordMinLength + "位密码",
                        group: "base"
                    }).vLength({
                        min: 6,
                        max: 20
                    }).vRegex({
                        pattern: /\w{6,20}/,
                        errorText: "请输入数值或英文字符"
                    });
                </script>
            </p>
            <p>
                <label for="ConfirmPasswordTextBox">
                    确认密码
                </label>
                <input id="ConfirmPasswordTextBox" type="password" />
                <script type="text/javascript">
                    $("#ConfirmPasswordTextBox").vCompare({ target: $("#Password"), errorText: "两次密码不一样" });
                </script>
            </p>
            <%if (Membership.RequiresQuestionAndAnswer)
              {%>
            <p>
                <label for="PasswordQuestion">
                    问题:
                </label>
                <%=Html.TextBoxFor(m => Model.PasswordQuestion)%>
                <script type="text/javascript">

                    $("#PasswordQuestion").vRequire({
                        errorText: "请填写取回密码的问题",
                        group:"base",
                    }).vLength({ min: 1, max: 50, errorText: "长度必须在1至50之间" });
                </script>
            </p>
            <p>
                <label for="AnswerTextBox">
                    答案:
                </label>
                <%=Html.TextBoxFor(m => Model.PasswordQuestion)%>
                <script type="text/javascript">
                    $("#PasswordQuestion").vRequire({
                        errorText: "请填写取回密码的答案",
                        group: "base"
                    }).vLength({ min: 1, max: 50, errorText: "长度必须在1至50之间" });
                </script>
            </p>
            <%
              }%>
        </div>
        <div id="choose" class="cssform">
            <p>
                <label for="NameTextBox">
                    名称:
                </label>
                <%=Html.TextBoxFor(m => m.Name)%>
                <script type="text/javascript">
                    $("#Name").vLength({ min: 1, max: 30, errorText: "长度必须在1至30之间" });
                </script>
            </p>
            <p>
                <label for="PhoneTextBox">
                    电话:
                </label>
                <%=Html.TextBoxFor(m => m.Information.Phone)%>
                <span id="PhoneTextBoxTip"></span>
            </p>
            <p>
                <label for="CommentTextBox">
                    备注:
                </label>
                <%=Html.TextAreaFor(m => m.Comment)%>
                <span id="CommentTextBoxTip"></span>
            </p>
        </div>
        <div id="2">
            <%Html.RenderPartial("../Role/RoleAssign"); %>
        </div>
        <div id="usergroup">
            <%Html.RenderPartial("../UserGroups/UserGroupSelector"); %>
        </div>
    </div>
    <%Html.EndForm();%>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="HeadContent" runat="server">
    <script src="/Scripts/jQuery.easyValidate.js" type="text/javascript"></script>
    <script src="/Scripts/jquery.json.min.js" type="text/javascript"></script>
    <script src="/Scripts/jquery.bindTools.min.js" type="text/javascript"></script>
    <script language="javascript" type="text/javascript">
    
    var passwordMinLength=<%=Membership.MinRequiredPasswordLength%>;
    var requiresQuestionAndAnswer=<%=Membership.RequiresQuestionAndAnswer.ToString().ToLower()%>;      
        
    $(document).ready(function() {        
        $('#CreateUser').tabs();       
        
        $("#backButton").button().click(function(){      
            location="Index";
         });
        $("#saveButton").button({icons:{primary:"ui-icon-plus"} }).click(function(){        
            return $.easyValidate('check');          
        });        
         
    });
  
    
    </script>
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="PageTitle" runat="server">
    创建用户
</asp:Content>
